package com.air.controller;

import com.air.entity.Dept;
import com.air.service.IDeptService;
import com.air.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private IDeptService deptService;

    @GetMapping("/list")
    public Result findAll() {
        return Result.ok().data("list", deptService.list());
    }

    @PostMapping("/add")
    public Result addDept(@RequestBody Dept dept){
        return deptService.save(dept) ? Result.ok().message("添加成功") : Result.error().message("添加失败");
    }
}
